/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package sistemperpustakaan.tablemodel;

import java.util.ArrayList;
import java.util.List;
import javax.swing.table.AbstractTableModel;
import sistemperpustakaan.entity.ViewBuku;

/**
 *
 * @author EKo
 */
public class BukuTableModel extends AbstractTableModel {

    List<ViewBuku> listBuku;
    String[] header = {"ID Buku", "No Panggil", "ISBN", "Judul", "Pengarang", "Penerbit", "Kota", "Tahun", "Bahasa", "Jenis", "Kategori", "Subyek", "Juml Halaman", "Tersedia", "Terpinjam", "Hilang","Jumlah"};

    public BukuTableModel() {
        listBuku = new ArrayList<ViewBuku>();
    }

    public void rowDataInserted(ViewBuku lb) {
        listBuku.add(lb);
        fireTableRowsInserted(getRowCount() - 1, getRowCount() - 1);
    }

    public void setListBuku(List<ViewBuku> listBuku) {
        this.listBuku = listBuku;
    }

    public int getRowCount() {
        return listBuku.size();
    }

    public int getColumnCount() {
        return 17;
    }

    public Object getValueAt(int rowIndex, int columnIndex) {
        return listBuku.get(rowIndex).getObject(columnIndex);
    }

    @Override
    public String getColumnName(int column) {
        return header[column];
    }


}
